import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4

Button {
    property bool primary: false
    property real pointSize: 10

    property color buttonColor: primary ? "#3498db" : "#e0e0e0"
    property color buttonTextColor: primary ? "#ffffff" : "#000000"
    property color buttonHighlightColor: "#2980b9"
    property color buttonHighlightTextColor: "#ffffff"

    property bool _showHighlight: pressed || hovered || checked

    style: ButtonStyle {
        padding {
            top: 6
            bottom: 6
            left: 12
            right: 12
        }

        background: Rectangle {
            implicitWidth: 100
            implicitHeight: 30
            border.width: 1
            border.color: control.buttonTextColor
            color: control._showHighlight ?
                   control.buttonHighlightColor :
                   control.buttonColor
        }

        label: Item {
            implicitWidth: row.implicitWidth
            implicitHeight: row.implicitHeight

            Row {
                id: row
                anchors.centerIn: parent
                spacing: 5

                Image {
                    source: control.iconSource
                    anchors.verticalCenter: parent.verticalCenter
                }

                Text {
                    anchors.verticalCenter: parent.verticalCenter
                    antialiasing: true
                    text: control.text
                    font.pointSize: pointSize
                    color: control._showHighlight ?
                           control.buttonHighlightTextColor :
                           control.buttonTextColor
                }
            }
        }
    }
}
